<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="shortcut icon" href="./img/logo.jpg">
    <link rel="stylesheet" href="css/blog.css">
    <link rel="stylesheet" href="css/login.css">
</head>

<body>
    <div class="nav">
        <img src="./img/logo.jpg" alt="">
        <span class="title">博客系统</span>
        <span class="spacer"></span>
        <a href="login.html">登录</a>
    </div>
    <div class="login-container">
        <div class="login-dialog">
            <form id="form" onsubmit="return false" action="##">
                <h3>注册</h3>
                <div class="row">
                    <span>用户名</span>
                    <input type="text" id="username" name="username">
                </div>
                <div class="row">
                    <span>密码</span>
                    <input type="password" id="password" name="password">
                </div>
                <br>
                <br>
                <br>
                <div class="row submit-row">
                    <input id = "submit" type="submit" value="注 册" onclick="reg()">
                </div>
            </form>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        function reg() {
            $.ajax({
                url: 'user/reg',
                type: "POST",
                data: $('#form').serialize(),
                datatype: "json",
                success: function (result) {
                    if (result.code == 200) {
                        location.assign('blog_list.html');
                    } else {
                        alert(result.data);
                    }
                }
            });
        }
    </script>
</body>

</html>